﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Strom.Server.IO;

namespace Strom.Server.Commands
{
    class DeleteAccountCommand : BaseCommand, IConsoleCommand
    {
        public void ExecuteWithParameters(string[] parameters)
        {
            if(parameters.Length != 1)
            {
                InvalidParameters();
                return;
            }

            lock (ServerDatas.Server.Database.AccountsList)
            {
                if (ServerDatas.Server.Database.AccountsList.RemoveAll(current => current.Infos.Login == parameters[0]) != 0)
                    ServerConsole.WriteSpecialMessageCommand("\tLe compte " + parameters[0] + " a été supprimé.", ServerConsole.MessageType.Success);
                else
                    ServerConsole.WriteSpecialMessageCommand("\tLe compte " + parameters[0] + " est introuvable.", ServerConsole.MessageType.Fail);
            }
        }

        public static string CommandName
        {
            get { return "acc_delete"; }
        }
    }
}
